package com.gem.service;

import java.util.List;

import com.gem.dao.UserDAO;
import com.gem.dao.impl.UserDAOImpl;
import com.gem.pojo.Users;

public class UsersService {
	UserDAO userdao = new UserDAOImpl();

	public boolean regist(Users user) {
		if (user.getUname().equals("") || user.getUpassword().equals("")) {
			
			return false;
		} else {
			if (user.getUpassword().length() < 6) {
				System.out.println("����������6λ ");
				return false;
			} else {
				return userdao.addUser(user);
			}
		}

	}// end regist(Users user)

	public boolean login(Users user) {

		if (user != null) {
			Users uu = userdao.getUser(user);
			if (uu!= null) {
				return true;
			}
		}
		return false;
		
	}

	public List<Users> getAllUsers() {
		return userdao.getAllUsers();
	}

	public boolean updateUserInfo(Users user) {
		if (user != null) {
			return userdao.updateUserInfo(user);
		} else {
			return false;
		}
	}
	public List<Users> getAllUsersByPage(int page_user_num, int page_num){
		List<Users> list=userdao.getAllUsersByPage(page_user_num, page_num);
		return list;
	}
	public Users getUserInfo(String uid) {
		if (uid != null && !uid.equals("")) {
			return userdao.getUserInfo(uid);
		}
		return null;
	}
	public int getUsersAcount() {
		return userdao.getUsersAcount();
	}
}
